<?php
$user_folder    = $this->session->userdata('image_folder');
$user_path       = 'public/' . $oRaoVat->image_folder .'/';
$raovat_img_path = UPLOAD_FOLDER_URL . $user_path . RAOVAT_IMAGE_URL;
$temp_img_path   = UPLOAD_FOLDER_URL . 'public/' . $user_folder . '/' . TEMP_FOLDER_URL;
$aRaoVatImage    = upload_modal_get($raovat_img_path);
$aTempImage      = upload_modal_get($temp_img_path);
?>
<div id="modal-change-image" class="modal fade" tabindex="-1" role="dialog" data-backdrop="static" aria-labelledby="myModalChangeImage" aria-hidden="true">
    <div class="modal-dialog modal-lg">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title" id="myModalLabel">Hình đại diện</h4>
            </div>
            <div class="modal-body">
                <div class="row">
                    <div class="image-current">
                        <form id="frm-upload-img" method="post" action="<?php echo admin_page_url('hinh-anh/tai-len'); ?>" enctype="multipart/form-data">
                            <div class="form-group col-md-8 col-md-offset-2 col-xs-12">
                                <div class="input-group">
                                    <input type="file" name="userfile" class="form-control" />
                                    <span class="input-group-btn">
                                        <button id="btn-change-img" class="btn btn-primary">
                                            <i class="glyphicon glyphicon-arrow-up"></i>
                                            Tải lên
                                            <span class="percent hidden">0%</span>
                                        </button>
                                    </span>
                                </div>
                            </div>
                            <div class="clearfix"></div>
                        </form>

                        <p class="image-section"><i class="glyphicon glyphicon-chevron-right"></i> Đang được sử dụng</p>
                        <ul class="image-list clearPad">
                            <?php foreach($aRaoVatImage as $img) { ?>
                            <li>
                                <a href="<?php echo raovat_upload($img, $oRaoVat->image_folder); ?>" class="thumbnail img-block-edit raovat-img-block" data-url-remove="<?php echo admin_page_url('hinh-anh/xoa'); ?>" data-folder='<?php echo RAOVAT_IMAGE_URL; ?>' data-name='<?php echo $img; ?>'>
                                    <img class="media-object" src="<?php echo raovat_upload($img, $oRaoVat->image_folder); ?>" />
                                </a>
                            </li>
                            <?php } ?>
                        </ul>
                        <ul class="image-list hidden">
                            <li class="hidden" id="raovat-temp-block">
                                <a href="#" class="li-temp thumbnail img-block-edit raovat-img-block" data-url-remove="<?php echo admin_page_url('hinh-anh/xoa'); ?>" data-folder='<?php echo TEMP_FOLDER_URL; ?>' data-name=''>
                                    <img class="media-object" src="" />
                                </a>
                            </li>
                        </ul>
                        <p class="image-section"><i class="glyphicon glyphicon-chevron-right"></i> Đã tải lên</p>
                        <ul id="image-temp-upload" class="image-list clearPad">
                            <?php foreach($aTempImage as $img) { ?>
                            <li>
                                <a href="<?php echo temp_image($img, $user_folder, false); ?>" class="thumbnail img-block-edit raovat-img-block" data-url-remove="<?php echo admin_page_url('hinh-anh/xoa'); ?>" data-folder='<?php echo TEMP_FOLDER_URL; ?>' data-name='<?php echo $img; ?>' >
                                    <img class="media-object" src="<?php echo temp_image($img, $user_folder, false, true); ?>" />
                                </a>
                            </li>
                            <?php } ?>
                        </ul>
                        <div class="clearfix"></div>
                    </div>
                    <div class="image-resize hidden">
                        <form id="frm-crop" method="POST" action="<?php echo admin_page_url('hinh-anh/crop'); ?>">
                            <div id="img-wrap" data-thumb-width="<?php echo POST_THUMB_W; ?>" data-screen-width="300">
                                <img src="" id="crop-target" data-ratio="<?php echo POST_THUMB_RATIO; ?>" />
                            </div>
                            <div class="inline-labels hidden">
                                <label>X1 <input type="hidden" size="4" id="x1" name="crop[x1]" /></label>
                                <label>Y1 <input type="hidden" size="4" id="y1" name="crop[y1]" /></label>
                                <label>X2 <input type="hidden" size="4" id="x2" name="crop[x2]" /></label>
                                <label>Y2 <input type="hidden" size="4" id="y2" name="crop[y2]" /></label>
                                <label>W  <input type="hidden" size="4" id="w"  name="crop[w]" /></label>
                                <label>H  <input type="hidden" size="4" id="h"  name="crop[h]" /></label>
                            </div>
                            <br />
                            <input type="hidden" id="input-crop-path" name="crop[path]" value=""/>
                            <input type="hidden" name="crop[w_case]" value="<?php echo RAOVAT_IMAGE_URL; ?>"/>
                            <button id="btn-crop" type="button" class="btn btn-success" name="submit">Cắt Hình</button>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>